// 循环调用红绿灯依次输出
function prored() {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve(red);
    }, 3000);
  });
}

function proyellow() {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve(yellow);
    }, 2000);
  });
}

function progreen() {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve(green);
    }, 1000);
  });
}

function red() {
  console.log('red');
}

function green() {
  console.log('green');
}

function yellow() {
  console.log('yellow');
}

function xunhuan() {
  prored()
    .then((a) => {
      a();
    })
    .then(() => {
      return proyellow();
    })
    .then((a) => {
      a();
    })
    .then(() => {
      return progreen();
    })
    .then((a) => {
      a();
      xunhuan();
    });
}
xunhuan()
